import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'
import path from 'path'
export const constantRoutes = [
  {
    path: '/',
    component: Layout,
    redirect: '/list',
    children: [
    ]
  },
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  }
]

export const asyncRoutes = [
  {
    path: '/list',
    component: Layout,
    redirect: '/list/dailyAdditions',
    alwaysShow: true, // will always show the root menu
    name: 'List',
    meta: {
      title: '活动记录',
      icon: 'lock',
      roles: ['admin', 'editor'] // you can set roles in root nav
    },
    children: [
      {
        path: 'dailyAdditions',
        component: () => import('@/views/list/dailyAdditions'),
        name: 'DailyAdditions',
        meta: {
          title: '每日登录',
          roles: ['admin']
        }
      },
      {
        path: 'completionRecords',
        component: () => import('@/views/list/completionRecords'),
        name: 'CompletionRecords',
        meta: {
          title: '用户完成度记录',
          roles: ['admin']
        }
      },
      {
        path: 'battleRecords',
        component: () => import('@/views/list/battleRecords'),
        name: 'BattleRecords',
        meta: {
          title: '用户发起战斗记录',
          roles: ['admin']
        }
      },
      {
        path: 'awardRecords',
        component: () => import('@/views/list/awardRecords'),
        name: 'AwardRecords',
        meta: {
          title: '获奖记录',
          roles: ['admin']
        }
      },
      {
        path: 'shareRecords',
        component: () => import('@/views/list/shareRecords'),
        name: 'ShareRecords',
        meta: {
          title: '分享统计记录',
          roles: ['admin']
        }
      },
      {
        path: 'prizeManagement',
        component: () => import('@/views/list/prizeManagement'),
        name: 'PrizeManagement',
        meta: {
          title: '奖品配置',
          roles: ['admin']
        }
      },
      
      
      
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
